/****************************************************************************
**
** Copyright (C) .  All rights reserved. 
**
****************************************************************************/

/*!
 * \file
 * defines global enumerators and structures
 */

#ifndef DEF_INTERFACE_H
#define DEF_INTERFACE_H


#define APIEXPORT __declspec(dllimport)

/*!
 * Global enumerator that shows a current play status
 */
enum PLAYER_STATE
{
	pst_stopped = 0,		//!< stop
	pst_open,
	pst_playforward,		//!< play forward
	pst_playbackward,		//!< play backward
	pst_stepnext,			//!< move 1 frame forward
	pst_stepnextkeyframe,	//!< move 1 key frame forward
	pst_stepprev,			//!< move 1 frame backward
	pst_stepprevkeyframe,	//!< move 1 key frame backward
	pst_pause,				//!< pause
	pst_count,
	pst_exit,
	pst_playpause,
};

/*!
 * Global enumerator for search mode
 */
enum SEARCH_TYPE
{
	search_time = 0,		//!< search from time list
	search_event,			//!< search from event list
	search_count
};

enum _PB_SPEED
{
	PB_SPEED_X1_4	= 0x008,
	PB_SPEED_X1_2	= 0x010,
	PB_SPEED_X1		= 0x020,
	PB_SPEED_X2		= 0x040,
	PB_SPEED_X4		= 0x080
};

/*!
 * Options associated with playback speed
 */
enum _PB_SPEED_OPTION
{
	PB_SPEED_OPT_ALL_FRAMES = 0,		//!< play all frames
	PB_SPEED_OPT_I_FRAME_X4,			//!< play I-frame only when playback speed is x4
	PB_SPEED_OPT_I_FRAME_X2,			//!< play I-frame only when playback speed is more than x2
};
/*!
 * This is commands from search.dll delivered by callback function
 */
enum _Cmd
{
	TIMELIST_LOAD,				//!< load the list to the time list
	EVENTLIST_OPTION = 12,
	EVENTLIST_LOAD,				//!< load the list to the event list
	MAP_STOP = 20,				//!< send command to stop working map
	POPUP_STREAM = 40,			//!< send video data selected for a pop-up screen or full screen purposes
	POPUP_STREAM_LOGO,			//!< inform to the application to draw logo image to the pop-up screen or full screen.
	GSENSOR_CLEAR = 60,			//!< send command to clear g-sensor data(graph)
	REPMGR_STOP = 70,			//!< Stopped by inside process

	ASK_RECOVERY_INDEX_TIME = 90,
	ASK_RECOVERY_INDEX_TIME_P,
	DO_RECOVERY_INDEX_TIME,
	POST_RECOVERY_INDEX_TIME,
	ASK_RECOVERY_INDEX_EVENT,
	ASK_RECOVERY_INDEX_EVENT_P,
	DO_RECOVERY_INDEX_EVENT,
	POST_RECOVERY_INDEX_EVENT,

	ASK_RECOVERY_FILEOPEN,
	DO_RECOVERY_FILEOPEN,

	FILE_OPEN_PROGRESS_START = 110,
	FILE_OPEN_PROGRESS_MID,
	FILE_OPEN_PROGRESS_INC,
	FILE_OPEN_PROGRESS_END,

	LIST_SORT = 120,	//!< sorts individual information to the recording information list
	LIST_RESET,			//!< resets recording information list
	LIST_INSERT,		//!< inserts individual information to the recording information list

	SEND_IMAGE = 130,	//!< during the play, send the current video data to the application
	SEND_AUDIO,			//!< during the play, send the current audio data to the application
	SEND_USER_DATA,		//!< during the play, send user data to the application
	SEND_USER_INFO,		//!< during the play, send information about GPS, G-Sensor etc to the application

	TIMELIST_GET_INDEX = 140,		//!< gets index information from time list
	TIMELIST_GET_INDEX_NO,			//!< gets an index number from time list
	TIMELIST_GET_SELECT_INDEX_NO,	//!< get an index number from time list, especially selected
	TIMELIST_SET_SELECT_INDEX,
	TIMELIST_GET_CHECK_INDEX_START,	//!< gets the first selected index number from time list
	TIMELIST_GET_CHECK_INDEX_NEXT,	//!< gets the next selected index number from time list.
	TIMELIST_GET_CHECK_INDEX_END,

	EVENTLIST_GET_INDEX = 150,		//!< gets index information from event list
	EVENTLIST_GET_INDEX_NO,			//!< gets an index number from event list
	EVENTLIST_GET_SELECT_INDEX_NO,	//!< gets an index number from event list, especially selected
	EVENTLIST_SET_SELECT_INDEX,

	EVENTLIST_GET_CHECK_INDEX_START,	//!< gets the first selected index number from event list
	EVENTLIST_GET_CHECK_INDEX_NEXT,		//!< gets the next selected index number from event list.
	EVENTLIST_GET_CHECK_INDEX_END,

	TIMEBAR_LOAD = 160,			//!< send information about the number of I-frames int the current file
	TIMEBAR_LOAD_START,
	TIMEBAR_LOAD_STOP,

	DISPLAY_VIDEO_STREAM = 170,		//!< send video stream to display. added from ver.1.3.1.19
	DISPLAY_UPDATE,					//!< trigger to update display surface. added from ver.1.3.1.19

	PLAY_AUDIO_DATA = 180,			//< send audio data to playback. added from ver.1.3.1.19
	PLAY_AUDIO_CREATE_BUFFER,		//< let audio object prepare to playback by creating DS buffer. added from ver.1.3.1.19
	PLAY_AUDIO_LOAD_STATUS,			//< check availability that buffer is loadable.
	PLAY_AUDIO_STOP,				//< stop playing audio.
};

/*!
 * Enumerators for using backup process
 */
enum _Bak
{
	PROGRESS_SETVAL = 0,
	FINISH_BAK,					//!< Finished a backup.

	BACKUP_GET_TIME_INDEX,		//!< Gets index information from the time list.
	BACKUP_GET_TIME_NEXT,		//!< Gets an index number from the time list.
	BACKUP_GET_TIME_NEXT_CHECKED,	//!< Gets an index number, which are checked, from the time list

	BACKUP_GET_EVENT_INDEX,		//!< Gets index information from the event list.
	BACKUP_GET_EVENT_NEXT,		//!< Gets an index number from the event list.
	BACKUP_GET_EVENT_NEXT_CHECKED,	//!< Gets an index number, which are checked, from the event list

};

enum _TAG_MAP
{
	MAP_CONNECTION = 0
};

enum _EvtOpt
{
	EVTOPT_ALL = 0,
	EVTOPT_EVENT,
	EVTOPT_MOTION,
	EVTOPT_EMERGENCY,
};

enum _TAG_REC_TYPE
{
	REC_NORMAL = 0,
	REC_EVENT,					//GSensor
	REC_PARKING,				//Motion, parking mode
	REC_MANUAL,					//Emergency, manual recording
};

#define MAX_REC_TYPE		4

/*!
 * Global enumerator for recording mode
 */
enum _tagRECMODE
{
	RECMODE_UNKNOWN = -1,			//!< unknown record mode
	RECMODE_UNIFIEDINDEX = 0,		//not used
	RECMODE_SEPERATEINDEX,
	RECMODE_SEPERATEFOLDER,
	RECMODE_NOINDEX,					//
	RECMODE_AVI_CURFOLDER,
	RECMODE_AVI_SEPERATE,
	RECMODE_AV2,					//!< AV2 files
	RECMODE_AVI,					//!< AVI files
	RECMODE_AVS,
};

/*!
 * Enumerators for backup mode
 */
enum _TAG_BACKUP_MODE
{
	bm_List1 = 0,			//!< Makes 1 avi file from current list
	bm_ListSelected,		//!< Makes several files depending on the list
	bm_Time					//!< Make 1 avi file from start to end referenced by the given time.
};


typedef struct _PLAY_INFO
{
	time_t tStart;
	time_t tEnd;
	time_t tPlay;
	int nIFrameIndexCount;
	int nPlay;
} ST_PLAY_INFO, *LPST_PLAY_INFO;


typedef struct _GpsRange
{
	DWORD	dwStart;
	DWORD	dwEnd;
} GpsRange, *PGpsRange;

typedef struct _GpsSetInfo
{
	DWORD	dwTime;
	float   fGpsN;
	float   fGpsE;
} GpsSetInfo, *PGpsSetInfo;

typedef struct _ExtStream
{
	BYTE*	pStream;
	DWORD	dwWidth;
	DWORD	dwHeight;
	DWORD   dwFid;
	int		nFormat;
} ExtStream, *PExtStream;

typedef struct _MapInfo
{
	float   fGpsN;
	float   fGpsE;
	float	fSpeed;
} MapInfo, *PMapInfo;

typedef struct _GSensorInfo
{
	float	fAccX;
	float	fAccY;
	float	fAccZ;
	int		nDir;
} GSensorInfo, *PGSensorInfo;

typedef struct _NotifyStop
{
	int nPrePlayMode;
	int nSearchType;
	BOOL bContinue;
} ST_NOTIFY_STOP, *LPST_NOTIFY_STOP;

typedef struct _IMAGE_DATA
{
	//raw image
	DWORD dwChannel;
	time_t tPlayTime;
	DWORD dwPlayTimeMillisec;
	BYTE *pImage;
	DWORD dwWidth;
	DWORD dwHeight;
	DWORD dwFormat;
	DWORD dwIFrameCount;
} ST_IMAGE_DATA, *LPST_IMAGE_DATA;

typedef struct _USER_DATA
{
	DWORD dwChannel;
	time_t tPlayTime;
	DWORD dwPlayTimeMillisec;
	BYTE *pUserFormat;
	DWORD dwUserFormatSize;
	BYTE *pUserData;
	DWORD dwUserDataSize;

	//////////////////////////////////////////////////////////////////////////
	//more info
	int nTotalIFrameCount;
	time_t tStartTime;
	time_t tEndTime;
	int nSearchType;
	int nCurIndex;
	//////////////////////////////////////////////////////////////////////////

} ST_USER_DATA, *LPST_USER_DATA;

typedef struct _AUDIO_DATA
{
	DWORD dwChannel;
	time_t tPlayTime;
	DWORD dwPlayTimeMillisec;
	BYTE *pAudioBuffer;
	DWORD dwSize;
	DWORD dwFreq;
	DWORD dwBitRate;
} ST_AUDIO_DATA, *LPST_AUDIO_DATA;

typedef struct _TIMEBAR_LOAD_DATA
{
	DWORD dwTotalCount;
	DWORD dwCurPos;
} ST_TIMEBAR_LOAD_DATA, *LPST_TIMEBAR_LOAD_DATA;

typedef struct _DISPLAY_VIDEO_STREAM
{
	int nSection;
	int nChannel;
	BYTE *pVideoBuffer;
	int nWidth;
	int nHeight;
	int nField;
	int nFormat;
	LONGLONG llPlayTime;
} ST_DISPLAY_VIDEO_STREAM, *LPST_DISPLAY_VIDEO_STREAM;

typedef struct _PLAY_AUDIO_DATA
{
	DWORD dwAudioFormat;
	DWORD dwFrequency;
	DWORD dwBitPerSample;
	BYTE *pAudioData;
	DWORD dwAudioDataSize;
	BOOL bResult;
}ST_PLAY_AUDIO_DATA, *LPST_PLAY_AUDIO_DATA;

/*!
 * Callback function type - CALLBACK_APP
 */
typedef void (*CALLBACK_APP)(UINT dwCmd, DWORD wParam, void *lParam, void* pApp); 
typedef CALLBACK_APP const PCALLBACK_APP;

/*!
 * Callback function type - CALLBACK_REPLAY
 */
typedef void (*CALLBACK_REPLAY)(UINT dwCmd, DWORD wParam, void *lParam, void* pApp); 
typedef CALLBACK_REPLAY const PCALLBACK_REPLAY;

typedef struct _CallbackInfo
{
	void*			callbackParam;
	void*			callbackProc;
} CallbackInfo, *PCallbackInfo;

#if 1
/*!
 * Global structure for AVI file name parsing
 * \brief used this structure in the structure _AVI_NAME_FORMAT for parsing a file name
 */
typedef struct _NAME_INFO
{
	TCHAR tzSeperator[32];
	TCHAR tzType[32];
	TCHAR tzMeaning[32];
	int nDigit;
} ST_NAME_INFO, *LPST_NAME_INFO;

/*!
 * Global structure for AVI file name parsing
 * \brief Recorded file name information for parsing a file
 */
typedef struct _AVI_NAME_FORMAT
{
	int nStartChannelNumber;	/**< first camera number 	*/
	int nInfoCount;				/**< the number of ST_NAME_INFO which it has 	*/
	LPST_NAME_INFO lpstNameInfo;	/**< information of name 	*/
} ST_AVI_NAME_FORMAT, *LPST_AVI_NAME_FORMAT;

/*!
 * Global enumerator for parsing AVI file name
 */
enum _TAG_NAME_PARSE
{
	E_FILENAME_IDENTIFIER = 0,	//!< prefix of file name
	E_CHANNEL_NUMBER,			//!< channel number
	E_INDEX,					//!< index number
	E_YEAR,						//!< information of year
	E_MONTH,					//!< information of month
	E_DAY,						//!< information of day
	E_HOUR,						//!< information of hour
	E_MINUTE,					//!< information of minute
	E_SECOND,					//!< information of second
	E_MILLISECOND,				//!< information of millisecond
	E_ELAPSE,					//!< shows elapse time
	E_RECTYPE,					//!< recording type
	E_DONT_CARE,				//!< information which means it will not bed used, dummy data
	E_MAX_FILE_FORMAT			//!< maximun number of the information
};

typedef struct _AVI_FMT_STRUCT
{
	int nOrder;
	BOOL bUse;
	BOOL bBar;

	int nLength;
	int nType;

	TCHAR tzString[32];
	int nInfo;

} ST_AVI_FMT_STRUCT, *LPST_AVI_FMT_STRUCT;

typedef struct _AVI_NAME_FORMAT2
{
	ST_AVI_FMT_STRUCT stFmtStruct[E_MAX_FILE_FORMAT];
	int nDepth;
} ST_FILE_NAME_FORMAT, *LPST_FILE_NAME_FORMAT;
#endif


#endif // DEF_INTERFACE_H